<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <div id="app">
        <fieldset>
            <legend>06.watch侦听器.html</legend>
            <h1>{{msg}}</h1>
            <h1>{{person.name}}</h1>
        </fieldset>
    </div>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    const vm = new Vue({
        el:"#app",
        data:{
            msg:"你不是真正的快乐",
            person:{
                name:"肖梦",
                girlFriend:{
                    name:"hhhh"
                }
            }
        },
        watch:{
            msg(newVal, oldVal){
                console.log(newVal);
                console.log(oldVal);
            },
            "person.girlFriend.name"(news,olds){
                console.log(news);
                console.log(olds);
            }
        }
    })
</script>